package com.bailiban.aigou.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bailiban.aigou.dao.ProductTypeDao;
import com.bailiban.aigou.entity.ProductType;
import com.bailiban.aigou.service.IProductTypeService;
import com.bailiban.aigou.utils.PageModel;

@Service
public class ProductTypeServiceImpl implements IProductTypeService {
	
	@Autowired
	private ProductTypeDao productTypeDao;

	@Override
	@Transactional
	public PageModel<ProductType> getProductTypes(PageModel<ProductType> pageModel) {
		PageModel<ProductType> productTypes = productTypeDao.getProductTypes(pageModel);
		int count = productTypeDao.getProductTypeCount();
		productTypes.setTotalRecords(count);
		return productTypes;
	}

	@Override
	@Transactional
	public List<ProductType> getAllProductType() {
		return productTypeDao.getAllProductType();
	}

	@Override
	@Transactional
	public ProductType getProductTypeById(String id) {
		return productTypeDao.getProductTypeById(id);
	}

}
